<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /*
        数组常用的方法：
         1.slice(start index,end index):从数组中提取一个或多个元素，结果返回数组【左闭右开】
         2.splice(起始索引index, 需要删除的个数, 第三个参数, 第四个参数...);
         3.concat():将两个数组拼接为一个
         4.join():将一个数组转换为字符串,toString()可以到达同样的功能
         */
        var arr = ["蔡徐坤", "范丞丞", "周震南", "小鬼"];
        /*
        //1.slice(start index,end index):从数组中提取一个或多个元素，结果返回数组【左闭右开】
        var newArr = arr.slice(0, 1);
        console.log(newArr);//["蔡徐坤']
        console.log(arr);//[ "范丞丞", "周震南", "小鬼"];
        //2.splice(start index,deleteDetail)：删除
        var newArr1 = arr.splice(0, 1);
        console.log(newArr1);//["蔡徐坤']
        console.log(arr);//[ "范丞丞", "周震南", "小鬼"];
        // splice(start index,deleteDetail,replaceMent):替换
        var newArr1 = arr.splice(0, 1, "虞书欣", "大嘴");
        console.log(newArr1);//["蔡徐坤']
        console.log(arr);//["虞书欣", "大嘴","范丞丞", "周震南", "小鬼"];
        */
        //3.concat():将两个数组拼接为一个
        var arr2 = [1, 2, 3];
        var arr3 = arr.concat(arr2);
        console.log(arr3);//["蔡徐坤", "范丞丞", "周震南", "小鬼", 1, 2, 3]
        //4.join():将一个数组转换为字符串,默认以逗号隔开,也可以传特殊符号隔开
         //var str=arr.join("*");
        var str=arr.toString();
        console.log(str);//蔡徐坤,范丞丞,周震南,小鬼

    </script>
</head>
<body>

</body>
</html>